<include file='public/_meta'>

<title>添加管理员 - 管理员管理</title>
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add" action="{:url('index/Custom/add')}" method="post">
	<div class="row cl">
        <label class="form-label col-xs-4 col-sm-3">
            车牌号码：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" id="search_text" name="car_sn" placeholder="请填写车牌号码" value="" class="input-text">
        </div>
    </div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机(登录账号)：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="请输入手机号" id="user_name" name="user_name">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="password" class="input-text" autocomplete="off"  placeholder="确认新密码" id="password2" name="password2">
		</div>
	</div>
	<div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>
            登录时长(分钟):</label>
        <div class="formControls col-xs-8 col-sm-9">
            <span class="select-box" style="width:300px;">
                <select class="select" name="minute" size="1">
                   <option value="">请选择</option>
                   <option value="10">10</option>
                   <option value="15">15</option>
                   <option value="20">20</option>
                   <option value="25">25</option>
                   <option value="30">30</option>
                   <option value="60">60</option>
                </select>
            </span>
        </div>
    </div>
    
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<include file='public/_footer'>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			car_sn:{
				required:true,
			},
			password:{
				required:true,
			},
			password2:{
				required:true,
				equalTo: "#password"
			},
			user_name:{
				required:true,
				isPhone:true,
			},
			minute:{
				required:true,
			}
			
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success: function(data) { 
                if(data['code']==1){
                
                	layer.msg(data['msg'], {icon:6,time:1000},function(){
                		var index = parent.layer.getFrameIndex(window.name);

						parent.location.href = '{:url('index')}';              		
						parent.layer.close(index);
						
                	});

                }else if(data['code']==2){
                	layer.msg("更新错误");

                }
                else{
                	layer.msg(data['msg']);

                }
            }


			});
		}
	});
});

$(function(){
    var url = "{:url('index/Record/ajaxGetCarSn')}";
    // var searchURL = "/cases/search.action";
    var isClicked = false;
    var defauntkeyword = "请输入关键词";
    $("#search_text").autocomplete(url, {
        scroll:false,
        selectFirst:false,
        delay:5,
        max:10,
        dataType:"json",//ajax的跨域，必须用jsonp,jQuery自动会加一个callback参数,后台要获得callback参数，并写回来
            //自定义提示
        tips:function(data) {
                //这里的data是跟formatItem 的data是一样的，所以格式也一样
            return data.pinyin;
        },
        parse: function(data) {
            if(data==null||typeof(data)=="undefined"||data.length==0){
                return null;
            }
            // console.log(data);

            // data = data.keylist;
            var rows = [];
            for(var i=0; i<data.length; i++){
                rows[rows.length] = {
                    data:data[i],//这里data是对象数组，格式[{key:aa,address:nn},{key:aa,address:nn}]
                    value:data[i].car_sn,
                    result:data[i].car_sn
                };
            } console.log(rows);
            return rows;
        },
        extraParams: {query:function (){return $('#search_text').val();}},
        formatItem: function(data, i, total) {  //就是下拉框显示的内容，可以有格式之类的
            return "<p class=''>"+data.car_sn+"</p>";
        },
        formatMatch: function(data, i, total) {  //要匹配的内容
            return data.car_sn;
        },
        formatResult: function(data) {  //最终在inputText里显示的内容，就是以后要搜索的内容
            return data.car_sn;
        }
    }).result(function(e, data) {
        if(!isClicked) {
            // startSearch();
        }
        if(data.car_id){
            $("#search_text").attr("value",data.car_id);
        }
    });

});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>